package com.bckj.freshnow.order.trade.fsm;

import com.alibaba.cola.statemachine.Action;
import com.bckj.freshnow.order.trade.fsm.enums.TradeOrderEventEnum;
import com.bckj.freshnow.order.trade.fsm.enums.TradeOrderStatusEnum;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class TradeOrderAction implements Action<TradeOrderStatusEnum, TradeOrderEventEnum, TradeOrderContext> {

    @Override
    public void execute(TradeOrderStatusEnum from, TradeOrderStatusEnum to, TradeOrderEventEnum event, TradeOrderContext ctx) {
        log.info("OrderAction execute from: {}, to: {}, event: {}, ctx: {}", from, to, event, ctx);
        ctx.setFrom(from);
        ctx.setTo(to);
        ctx.setEvent(event);
        switch (event) {
            case PAY_SUCCESS -> {

            }
            case CANCEL_ORDER -> {

            }
        }
    }
}
